import commonService from 'service/common'
import Qs from 'querystring'
export default {
    async login(data) {
        let dataObj = Object.assign({
            userId: '',
            passwd: ''
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'login.action',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    async stateHome(data) {
        let dataObj = Object.assign({
            userId: ''
        }, data)

        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'post',
            url: 'webapi/role/category',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //登录接口
    async login_goto(data, callback) {
        let dataObj = Object.assign({
            'userId': '',
            'passwd': '',

        }, data)

        dataObj = Qs.stringify(dataObj)
        let paramsJson = {
            baseURL: '/webapiThird1',
            method: 'post',
            url: '/ifly_auth/login.action',
            data: dataObj,
            callback: callback,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' },
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //  登出接口
    async logout(data) {
        let dataObj = Object.assign({

        }, data)

        let paramsJson = {
            baseURL: '/webapiThird1',
            method: 'get',
            url: '/auth/logout',
            params: dataObj,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' },
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // //  获取用户信息接口
// async user_info(data, callback) {
//     let dataObj = Object.assign({
//
//     }, data)
//
//     let paramsJson = {
//         baseURL: '/webapiThird1',
//         method: 'get',
//         url: '/auth/userInfo',
//         params: dataObj,
//         headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' },
//     }
//     let jsondata = await commonService.asyncFetchData(paramsJson)
//     return jsondata
// },
    //  登陆管理端
    async loginManage(data) {
        let dataObj = Object.assign({
            userId: '',
            passwd: ''
        }, data)

        let paramsJson = {
            baseURL: '/ifly',
            method: 'post',
            url: '/ifly_auth/login.action',
            data: dataObj,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' },
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //查询菜单
    async getMenuList(data) {
        let dataObj = Object.assign({
            userId: '',
            roleType: 'V'
        }, data)

        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'post',
            url: 'webapi/menu/tree',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    }

}